{include file="top.html"}
<div id="main" class="w-full">
	<div id="page-find-password" class="w-full page-auth mt20 mb20">
		<div class="wrap">
			<div class="w logo mt10"> <a href="{$siteUrl}" title="{$app->params['site_title']}"><img height="60"
						alt="{$app->params['site_title']}" src="{$app->params['site_logo']|url_format}" /></a> </div>
			<div class="form clearfix w">
				<div class="password_box">
					<div class="flowsteps">
						<ol class="num4 J_Step">
							<li class="current"><span class="first">1.输入账户名</span></li>
							<li class="next"><span>2.验证身份</span></li>
							<li><span>3.重置密码</span></li>
							<li><span class="last">4.完成</span></li>
						</ol>
					</div>
				</div>
				<form id="find_password_form" method="post">
					<div class="w">
						<dl class="clearfix">
							<dt>{$lang.your_username}</dt>
							<dd class="clearfix">
								<input type="text" class="input" name="username" />
								<i class="i-name"></i>
							</dd>
						</dl>
						<dl class="clearfix">
							<dt>{$lang.captcha}</dt>
							<dd class="captcha clearfix">
								<input type="text" class="input float-left" name="captcha" id="captcha1" />
								<a href="javascript:;" class="float-left mt5"><img onclick="change_captcha($(this))"
										id="captcha" src="{url route='default/captcha' v=uniqid('', true)}"
										class="float-left" height="38" /></a>
							</dd>
						</dl>
						<dl class="clearfix">
							<dt>&nbsp;</dt>
							<dd>
								<input type="hidden" name="codeType" value="" />
								<input type="hidden" name="code" value="" />
								<input type="submit" value="{$lang.submit}" class="fp-submit"
									title="{$lang.find_password}" />
							</dd>
						</dl>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	$(function () {
		$('#find_password_form').validate({
			errorPlacement: function (error, element) {
				var error_td = element.parent('dd');
				error_td.find('i').removeClass('ok');
				error_td.find('label').hide();
				error_td.append(error);
			},
			success: function (label) {
				label.siblings('i').addClass('ok');
				label.remove();
			},
			submitHandler: function (form) {
				if ($('input[name="codeType"]').val() != '' && $('input[name="code"]').val() != '') {
					form.submit();
				} else {
					$('.J_Step li:first').removeClass('current').addClass('done');
					$('.J_Step li:first').next('li').removeClass('next').addClass('current');
					$('.J_Step li:first').next('li').next('li').addClass('next');
					var username = $.trim($('input[name="username"]').val());
					$.getJSON(url(['default/checkUser', { username: username }]), function (res) {
						if (!res) {
							ajax_form('find_password', lang.captcha, url(['gselector/verifycode', { title: lang.captcha, id: 'find_password', username: username }]), '500', '', '0.45');
						} else {
							layer.msg(lang.no_such_user);
						}
					})
					return false;
				}
			},
			onkeyup: false,
			rules: {
				username: {
					required: true
				},
				captcha: {
					required: true,
					remote: {
						url: "{url route='default/checkCaptcha'}",
						type: 'get',
						data: {
							captcha: function () {
								return $('#captcha1').val();
							}
						}
					}
				}
			},
			messages: {
				username: {
					required: '{$lang.username_required}'
				},
				captcha: {
					required: '{$lang.captcha_required}',
					remote: '{$lang.captcha_error}'
				}
			}
		});
	});
	function gs_callback(id, codeType, code) {
		$('input[name="codeType"]').val(codeType);
		$('input[name="code"]').val(code);
		DialogManager.close(id);
		$('#find_password_form').submit();
	}
</script>
{include file="footer.html"}